package com.bluetrum.devicemanager.cmd.request;

import androidx.annotation.Nullable;

import java.util.HashMap;
import java.util.Map;

public final class BassEngineRequest extends TlvRequest {

    public static final byte BASE_ENGINE_STATUS = 1;
    public static final byte BASE_ENGINE_VALUE  = 2;

    private final Boolean enable;
    private final Byte value;

    private BassEngineRequest(@Nullable Boolean enable,
                              @Nullable Byte value) {
        super(COMMAND_BASS_ENGINE);
        this.enable = enable;
        this.value = value;

        // invoke before use getPreGeneratedPayload()
        generatePayload();
    }

    public static BassEngineRequest enableRequest(boolean enable) {
        return new BassEngineRequest(enable, null);
    }

    public static BassEngineRequest valueRequest(byte value) {
        return new BassEngineRequest(null, value);
    }

    @Override
    protected Map<Byte, Object> getTlvObjectMap() {
        return new HashMap<Byte, Object>() {{
            put(BASE_ENGINE_STATUS, enable);
            put(BASE_ENGINE_VALUE, value);
        }};
    }

    @Override
    public byte[] getPayload() {
        return getPreGeneratedPayload();
    }
}
